package com.czmh.etc.onlinepubsys.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Profile;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
* SwaggerConfig
 * @author sevenchen
*/
@Configuration
@EnableSwagger2
@Profile({"dev","test","pro"})
public class Swagger2Configuration {
	@Bean
	public Docket accessToken() {
		return new Docket(DocumentationType.SWAGGER_2)
				// 选择那些路径和api会生成document
				.select()
				//对所有api进行监控
				.apis(RequestHandlerSelectors.any())
				//只生成被ApiOperation这个注解注解过的api接口
				.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
				//对所有路径进行监控
				.paths(PathSelectors.any())
				.build()
				.apiInfo(apiInfo());
	}

	private ApiInfo apiInfo() {
		return new ApiInfoBuilder()
				.title("ETC线上发行系统")
				.description("ETC线上发行系统")
				.termsOfServiceUrl("")
				.contact(new Contact("seven", "", ""))
				.version("1.0.0")
				.build();
	}
}
